<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>RemoteControl_en.htm</TITLE>
<style>body{font: 10pt Verdana,sans-serif;}</style>
</HEAD>
<BODY LANG="en-US">
<PRE>

Last update: 2013-02-25

<h2>RemoteControl gCAD3D</h2> 
 
<A HREF='#rc1'>What is RemoteControl</A>

<A HREF='#PRI'>PRI</A>(text)            // print text (into messagewindow)
<A HREF='#ADD'>ADD</A>(code)            // process and store source-objects
<A HREF='#ADF'>ADDFILE</A>(filNam)      // process and store cad-objects in file 
<A HREF='#MOD'>MOD</A>(code)            // modify cad-code, update
NEW                  // save active model if modified, then clear whole model
CLEAR                // clear whole model - do not save model if modified
MODSIZ(newsize)      // change modelsize; use 'END' to update.
END                  // reprocess whole model

<A HREF='#SYM'>GETSYMDIR</A>(sym)       // returns path for symbolic-directory <sym>
<A HREF='#SYM'>SETSYMDIR</A>(sym,path)  // set new symbolic-directory
<A HREF='#SYM'>DELSYMDIR</A>(sym)       // delete symbolic-directory <sym>

<A HREF='#LOA'>LOAD</A>(modelname)      // clear and load new model (native, step, iges, dxf ..)
<A HREF='#LSM'>LOADSM</A>(submodel)     // load submodel (can only load native models (.gcad))

<A HREF='#SAV'>SAVE</A>                 // save model with current modelname
<A HREF='#SAV'>SAVE</A>(new_modelname)  // save model with given modelname

ZOOMALL              // set zoomfactor to view all objects
<A HREF='#VIE'>VIEW</A>(center, scale, rotAng, tiltAng)  // define view;
<A HREF='#SHO'>SHOW</A>(obj,off)        // hide object
<A HREF='#SHO'>SHOW</A>(obj)            // show hidden object
<A HREF='#ATL'>ATTL</A>(linetypNr,objects) // change linetype for objects
<A HREF='#ATS'>ATTS</A>("code",objects) // change surface-attribute
<A HREF='#LDT'>LOADTEX</A>(texFilNam)   // load texturefile (image)

ERRCLR               // returns errcode and clears error; 0=OK
GETMODSIZ            // get current modelsize
<A HREF='#GOI'>GETOBJINDNXT</A>(P)      // get next free object-index
<A HREF='#GLN'>GETLNR</A>               // get current lineNr
<A HREF='#DFO'>DELFOLL</A>(lnr)         // delete all lines following lineNr'
<A HREF='#USE'>USER</A>                 // get object from user (selection); Esc: empty.
<A HREF='#DUM'>DUMP</A>(list)           // dump list to console-window
<A HREF='#MOD'>MODE</A>(widget,off|on)  // hide or show subwindows: browser, menu, toolbars ..
WAIT_ESC             // stop until ESC - key becomes pressed
SYSTEM               // do operating-system command, wait; eg "SYSTEM(pluma /tmp/t1)"
EXIT                 // shut down gcad3d


__________________________________________________________________________
<p><a name="rc1"></a></p>
<b>What is RemoteControl</b>



RemoteControl has 3 modes: 
- External-control - do cad-operations from a terminal or process outside gcad (remote)
- StartRemote      - start a RemoteControlScript at startup
- Internal-control - start a RemoteControlScript from menu "Remote"


<b>External-control:</b>

With RemoteControl you can control the cad-program gCAD3D from programs.
All programming languages can be used, even shell-scripts.
For input and output 2 pipes (Linux; MS-Windows: Files) are used.
Input/outputpipe are created in directory {tmpdir}.
The temp-directory of gcad is indicated at strtup in the console-window -
  (eg Unix " basdir = |/mnt/serv2/devel/gcad3d/|")
  for default-installation this is:
Linux:
  the inputpipe is ${HOME}/gCAD3D/tmp/CTRLpin;
  the outputpipe is ${HOME}/gCAD3D/tmp/CTRLpout.
MS_Windows:
  Input from %APPDATA%\gCAD3D\tmp\CTRLpin
  Output to %APPDATA%\gCAD3D\tmp\CTRLpout

A system-variable can be set - 
  Unix "RCTL=/mnt/serv2/devel/gcad3d/CTRLpin"
    Command scan be sent now to $RCTL
  MS-Win: set RCTL="%APPDATA%\gCAD3D\tmp\CTRLpin"
    Command scan be sent now to %RCTL%


Input and output is done with textcodes, not binary.
You can send commands from a terminalprogram (Linux: xterm oder gnome-terminal; MS-Windows: cmd)
  to gcad (example: clear active model):
Linux:
  echo 'new' > ~/gCAD3D/tmp/CTRLpin
  or
  echo 'new' > $RCTL
MS_Windows:
  echo new>"%APPDATA%\gCAD3D\tmp\CTRLpin"
  or
  echo new>%RCTL%

Send a commandfile to remoteControl:
 - put the following 4 lines into  file t1.cmd:
new
add(P1=P(100 0 0))
add(C1=P1 50)
#eof

Send the file:
Linux:
  cat t1.cmd > ~/gCAD3D/tmp/CTRLpin
  or 
  cat t1.cmd > $RCTL
MS_Windows:
  copy t1.cmd "%APPDATA%\gCAD3D\tmp\CTRLpin"
  or
  copy t1.cmd %RCTL%


Receiving output from gcad (eg display the output in a terminal-window):
Linux (keeps connection):
  cat  ~/gCAD3D/tmp/CTRLpout
MS_Windows (new file after each remote-command):
  type %APPDATA%\gCAD3D\tmp\CTRLpout

Gcad sends after each command at least a new-line-character (ascii 10).


If you want to activate the program from "Remote/ Select-Start":
  Put start-scripts into directory <binDir>/remote
  Put executables into directory <binDir>



<b>Programming Examples:</b>
VB.Net (MS-Windows): <A HREF="../../prg/Demo1gCadRemoteControl.zip">Demo1gCadRemoteControl.zip</A>
Java: <A HREF="../../prg/DemoRC1.java">DemoRC1.java</A>

All following examples are linux-examples.

Please send improved examples or examples for other programming-languages to
 support at gcad3d.org


<b>StartRemote</b>
RemoteControlScripts can be executed at startup using:
gcad3d rcmd <filename>.cmd

Example: see file Data/prg/sample_cmd1.cmd
   (to see the path for directory "Data" do Standards/edit directory-path-group)



<b>Internal-control:</b>
Start a RemoteControlScript with Menu Remote/Select ..




__________________________________________________________________________
<p><a name="PRI"></a></p>
PRI(text)              // print text (into messagewindow)

Objects (points, vectors, variables) are decoded.

Example:
echo 'pri("TestPrint 1")' > ~/gCAD3D/tmp/CTRLpin
# display coordinates of point p1 and vector D1 with:
echo 'pri("P20 = ",P20," D20 = ",D20)' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="GLN"></a></p>
<p><a name="DFO"></a></p>
GETLNR               // get current lineNr
DELFOLL(lnr)         // delete all lines following lineNr

# lineNr from GETLNR can eg later be used for DELFOLL
#   (delete all objects created after getting 'GETLNR')


__________________________________________________________________________
<p><a name="GOI"></a></p>
GETOBJINDNXT(typ)     // get next free object-index for points


# example: get next free DB-index for type point:
echo 'GETOBJINDNXT(P)' > ~/gCAD3D/tmp/CTRLpin
# See list of <a href="CAD_Base_en.htm#Codeletters">objecttypes</a>


__________________________________________________________________________


__________________________________________________________________________
<p><a name="ADD"></a></p>
ADD(code)            // process and store source-objects

# code is any valid gcad-text; see <a href="CAD_Base_en.htm#Codes">Codes</a>
# eg create a point with:
echo 'add(P1=P(100 0 20))' > ~/gCAD3D/tmp/CTRLpin

__________________________________________________________________________
<p><a name="ADF"></a></p>
ADDFILE(filNam)      // process and store cad-objects in file

echo 'addfile("t1")' > ~/gCAD3D/tmp/CTRLpin

Example for file t1:
MODE(MEN,off)
MODE(BRW,off)
MODE(BAR1,off)
MODE(BAR2,off)
new
add(P1=P(100 0 0))
add(C1=P1 50)
zoomall
#eof


__________________________________________________________________________
<p><a name="MOD"></a></p>
MOD(code)            // modify cad-code, update


Example:
echo 'MOD(V1=70)' > ~/gCAD3D/tmp/CTRLpin

# modifies the line "V1=50" in the existing code:
# and updates the variable V1 and the circle C1.

P1=P(100 100 0)
V1=50
C1=P1 V1


__________________________________________________________________________
<p><a name="SYM"></a></p>
GETSYMDIR(sym)       // returns path for symbolic-directory <sym>
SETSYMDIR(sym,path)  // set new symbolic-directory
DELSYMDIR(sym)       // delete symbolic-directory <sym>


# get absolute path for (existing) symbol "Data"
echo 'GETSYMDIR("Data")' > ~/gCAD3D/tmp/CTRLpin

# set new symbol "myPath" to path "/tmp/gcad/"
echo 'SETSYMDIR("myPath","/tmp/gcad/")' > ~/gCAD3D/tmp/CTRLpin

# delete symbol "myPath"
echo 'DELSYMDIR("myPath")' > ~/gCAD3D/tmp/CTRLpin

# clear error
echo 'ERRCLR' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="LOA"></a></p>
LOAD(modelname)      // clear and load new model (native, step, iges, dxf ..)


Load models; filename can be symbolic, relativ or absolut.
# Example symbolic-filename:
echo 'load("Data/sample_area1.gcad")' > ~/gCAD3D/tmp/CTRLpin
# Example relative-filename (using current symbolic directory):
echo 'load("../dat/sample_area2.gcad")' > ~/gCAD3D/tmp/CTRLpin
# Example absolute-filename:
echo 'load("/tmp/test1.gcad")' > ~/gCAD3D/tmp/CTRLpin


echo 'MODSIZ(10000)' > ~/gCAD3D/tmp/CTRLpin
echo 'END' > ~/gCAD3D/tmp/CTRLpin


<p><a name="LSM"></a></p>
LOADSM(submodel)     // load submodel (can only load native models (.gcad))

# submodels need to be in a symbolic directory. See SETSYMDIR.
# Example load submodels, use submodels:
echo 'new' > ~/gCAD3D/tmp/CTRLpin
echo 'loadsm("Data/sample_mod_blech1.gcad")' > $RCTL
echo 'loadsm("Data/sample_mod_screw1.gcad")' > $RCTL
echo 'loadsm("Data/sample_mod_nut1.gcad")' > $RCTL
echo 'add(M20="Data/sample_mod_blech1.gcad" P(0 10 0))' > $RCTL
echo 'add(M21="Data/sample_mod_screw1.gcad" P(30 36.5 67))' > $RCTL
echo 'add(M22="Data/sample_mod_nut1.gcad" P(36 36.5 67))' > $RCTL

or copy into file test.cmd:
new
loadsm("Data/sample_mod_blech1.gcad")
loadsm("Data/sample_mod_screw1.gcad")
loadsm("Data/sample_mod_nut1.gcad")
add(M20="Data/sample_mod_blech1.gcad" P(0 10 0))
add(M21="Data/sample_mod_screw1.gcad" P(30 36.5 67))
add(M22="Data/sample_mod_nut1.gcad" P(36 36.5 67))
# eof

and execute with -
Unix:
  cat test.cmd > $RCTL
MS-Win:
  copy test.cmd %RCTL%

__________________________________________________________________________
<p><a name="SAV"></a></p>
SAVE                 // save model with current modelname
SAVE(new_modelname)  // save model with given modelname

# save active model as "test1.gcad" in symbolic direcory "Data". See SETSYMDIR.
echo 'save("Data/test1.gcad")' > ~/gCAD3D/tmp/CTRLpin

# quick-save
echo 'save' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="VIE"></a></p>
VIEW(center, scale, rotAng, tiltAng)  // define view;

# change view-scale
echo 'view(0.25)' > ~/gCAD3D/tmp/CTRLpin

# change view by rotation-angle and tilt-angle (degrees)
echo 'view(ang(45) ang(30))' > ~/gCAD3D/tmp/CTRLpin

# move view (change center-of-screen-point)
echo 'view(P(38 49 7))' > ~/gCAD3D/tmp/CTRLpin

__________________________________________________________________________
<p><a name="SHO"></a></p>
SHOW(obj,off)        # hide object
SHOW(obj)            # show hidden object


# hide line L21
echo 'show(L21,off)' > ~/gCAD3D/tmp/CTRLpin

# show hidden line L21
echo 'show(L21)' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="DUM"></a></p>
DUMP(<DB-obj-ID>)    # Dump geometric structure of database-object

DUMP("GA")           # dump Grafic_Attributes_list
DUMP("DL")           # dump display-list
DUMP("AT")           # dump linetypetable
DUMP("TX")           # dump textures
DUMP("SD")           # dump all symbolic directories

Examples:
echo 'DUMP(C20)' > ~/gCAD3D/tmp/CTRLpin
echo 'DUMP("GA")' > ~/gCAD3D/tmp/CTRLpin



__________________________________________________________________________
<p><a name="MOD"></a></p>
MODE(widget,off|on)    // Hide/restore menu, browser, upper toolbar, messagebar.

# menu off
echo 'MODE(MEN,off)' > ~/gCAD3D/tmp/CTRLpin

# browser off
echo 'MODE(BRW,off)' > ~/gCAD3D/tmp/CTRLpin

# upper toolbar off
echo 'MODE(BAR1,off)' > ~/gCAD3D/tmp/CTRLpin

# messagewindow off
echo 'MODE(BAR2,off)' > ~/gCAD3D/tmp/CTRLpin

# Restore messagewindow.
echo 'MODE(BAR2,on)' > ~/gCAD3D/tmp/CTRLpin



__________________________________________________________________________
<p><a name="ATL"></a></p>
ATTL(linetypNr,objects)             // apply predefined linetype to object


# linetypNr 0 - 12 are predefined in file ~/gCAD3D/cfg_{os}/ltyp.rc
# See <a href="Settings_en.htm#Linetypes">Defaultsettings</a>

# use linetypNr=8 for L21 and L22
echo 'ATTL(8,L21,L22)' > ~/gCAD3D/tmp/CTRLpin

# change/create linetype (G<linetypNr> = color,linetyp,thick)
# create linetype G13: green, full-line, thick=4 with:
echo 'add(G13=3,0,4))' > ~/gCAD3D/tmp/CTRLpin

# set linetypNr=13 for L21 and L22
echo 'ATTL(13,L21,L22)' > ~/gCAD3D/tmp/CTRLpin



__________________________________________________________________________
<p><a name="ATS"></a></p>
ATTS("code",objects)                          // change surface-attribute


Examples:
# set surface A21 symbolic (not shaded)
echo 'ATTS("S" A21)' > ~/gCAD3D/tmp/CTRLpin

# reset previous color (default-colour)
echo 'ATTS("C" A21)' > ~/gCAD3D/tmp/CTRLpin

# set color green (red-share-0, green-share-255, blue-share-0)
echo 'ATTS("C00ff00" A21)' > ~/gCAD3D/tmp/CTRLpin

# set transparent  (T0=reset, T1=half transparent, T2=full transparent)
echo 'ATTS("T2" A21)' > ~/gCAD3D/tmp/CTRLpin

<p><a name="LDT"></a></p>
# load texture and make active. Textures must be in symbolic directory.
echo 'LOADTEX("DIR_BMP/Ziegel1.bmp")' > ~/gCAD3D/tmp/CTRLpin

# apply texture to surface A21; set hor./vert.scales to "0.5,0.5".
# ATTS("Xscale,offset,angle",objects) // apply active texture
echo 'ATTS("X0.5,0.5" A21)' > ~/gCAD3D/tmp/CTRLpin


__________________________________________________________________________
<p><a name="USE"></a></p>
USER                                // get object from user (selection); Esc: empty.


# get user-selection;
echo 'USER' > ~/gCAD3D/tmp/CTRLpin
# returns "SEL(P(-3.244327 -10.077265 0.000000))"  for indicate position or
# returns "SEL(C16)"                               for selection of obj C16 or
# returns "SEL()"                                  for key esc pressed.



</PRE>
</BODY>
</HTML>
